package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.shopping.dal.persistence.PanelMapper;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.CcProductDetailDto;

import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * @Author: cc
 * @Date: 2022-08-25 08:52
 * @Description: 商品模块 9 10 11接口
 */

@RestController
public class CcShoppingController {


    @Autowired
    IProductService iProductService;



    /**
     * Todo:查看商品详情
     */

    @GetMapping("/shopping/product/{id}")
    public ResponseData shopProductDetail(@PathVariable Long id){

        CcProductDetailDto productDetail = iProductService.getProductDetail(id);

        return new ResponseUtil().setData(productDetail);
    }


    /**
     * Todo:查询推荐商品
     *
     */

    @GetMapping("/shopping/recommend")
    public ResponseData recommendGoods(){

        PanelDto panelDto = iProductService.getRecommendGoods();

        return new ResponseUtil().setData(panelDto);
    }


    /**
     * Todo:分页查询商品列表
     */

    @GetMapping("/shopping/goods")
    public ResponseData shoppingGoods(PageRequest pageRequest){

        AllProductResponse  allProductResponse = iProductService.getAllProduct(pageRequest);

        return new ResponseUtil().setData(allProductResponse);
    }
}
